package cn.tedu.charging.cost.dao.repository.impl;
import cn.tedu.charging.cost.dao.repository.CostRuleCacheRepository;
import cn.tedu.charging.cost.pojo.po.CostRulePO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public class CostRuleCacheRepositoryImpl implements CostRuleCacheRepository {
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public List<CostRulePO> getCostRuleByStationId(Integer stationId) {
        ValueOperations<String,List<CostRulePO>> vo = redisTemplate.opsForValue();
        List<CostRulePO> list = vo.get("COST_RULE_KEY_" + stationId);
        return list;
    }
    @Override
    public void saveCostRule(Integer stationId, List<CostRulePO> dbCostRules) {
        ValueOperations<String,List<CostRulePO>> vo = redisTemplate.opsForValue();
        vo.set("COST_RULE_KEY_" + stationId,dbCostRules);
    }
}
